<?php
session_start();
require("../database.php");
include("header.php");
?>
<link href="../quiz.css" rel="stylesheet" type="text/css">
<?php

extract($_POST);

echo "<BR>";
if (!isset($_SESSION[alogin]))
{
	echo "<br><h2><div  class=head1>You are not Logged On Please Login to Access this Page</div></h2>";
	echo "<a href=index.php><h3 align=center>Click Here for Login</h3></a>";
	exit();
}
//echo "<BR><h3 class=head1>Subject Add </h3>";

echo "<table width=100%>";
echo "<tr><td align=center></table>";
if($submit=='submit' || strlen($subname)>0 )
{
$rs=mysql_query("select * from mst_subject where sub_name='$subname'");
if (mysql_num_rows($rs)>0)
{
	echo "<br><br><br><div class=head1>Subject is Already Exists</div>";
	exit;
}
mysql_query("insert into mst_subject(sub_name) values ('$subname')",$cn) or die(mysql_error());
echo "<h2><p  align=center>Subject  <b> <i>$subname</i> </b> Added Successfully.</p></h2>";
$ts=mysql_query("select * from mst_subject where sub_name='$subname'");
if(mysql_num_rows($ts)>0 )
{
$mysql_query="select sub_id  from mst_subject where sub_name='$subname'";
$mysql_st=mysql_query($mysql_query);
$mysql_1= mysql_fetch_array($mysql_st);
$subid = $mysql_1[0];
//echo "$mysql_11";
mysql_query("insert into mst_test(sub_id,test_name,total_que) values ('$subid','$testname','$totque')",$cn) or die(mysql_error());
echo "<h2><p align=center>Test <b><i>$testname</i></b> Added Successfully.</p></h2></br></br></br>";
echo "<h3><a align=left style='margin-left:300px; padding:100px' href='subadd.php'>return back</a>";
echo "<a align=right style='margin-right:300px; padding:100px' href='questionadd.php'>To add Questions click here</a></h3>";
$submit="";
}
}
?>
